<template>
  <el-switch
    v-model="modelValue"
    active-color="#13ce66"
    inactive-color="#ff4949"
  >
  </el-switch>
</template>
<script>
export default {
  name: "EnabledSwitch",
  props: {
    value: {
      type: [Number, Boolean],
      default: () => 0,
    },
    type: {
      type: String,
      default: () => "Number",
    },
  },
  computed: {
    modelValue: {
      get() {
        if (this.type === "Boolean") {
          return this.value;
        }
        return this.value === 1;
      },
      set(val) {
        if (this.type === "Boolean") {
          this.$emit("update:value", val);
        } else {
          this.$emit("update:value", val ? 1 : 0);
        }
      },
    },
  },
};
</script>
<style lang="scss" scoped></style>
